package com.kgc.javaweb.util;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author: mosin
 * @version: v1.0  2022/11/1
 */
public class JsonResultWriter {


    public  static void   writerJson(HttpServletResponse response,Object data){

        response.setContentType("application/json;charset=utf-8");
        try {
            PrintWriter writer = response.getWriter();
            JSONObject jsonObject = JSONUtil.parseObj(data);
            jsonObject.setDateFormat("yyyy-MM-dd");
            String s = jsonObject.toString();
            writer.write(s);
            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
